package gui.panels.statistics;

import gui.components.AntiAliasedLabel;

import java.awt.Color;
import java.awt.Component;

import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.table.TableCellRenderer;

public class GameHistoryTableRenderer extends JPanel implements TableCellRenderer {

    private static final long serialVersionUID = 1L;
    private AntiAliasedLabel label;
    
    public GameHistoryTableRenderer(int padding, int fontSize) {
        add(label = new AntiAliasedLabel("", fontSize));
        setBorder(BorderFactory.createCompoundBorder(
                BorderFactory.createLineBorder(Color.GRAY),
                BorderFactory.createEmptyBorder(padding, padding, padding, padding)
        ));
    }
    
    @Override
    public Component getTableCellRendererComponent(JTable table, Object value,
            boolean isSelected, boolean hasFocus, int row, int column) {
        label.setText((value==null) ? "" : value.toString());
        setBackground(table.getBackground());
        return this;
    }

}
